1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module soup.Cache;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import soup.SessionFeatureIF;
31 private import soup.SessionFeatureT;
32 private import soup.c.functions;
33 public  import soup.c.types;
34 
35 
36 /** */
37 public class Cache : ObjectG, SessionFeatureIF
38 {
39 	/** the main Gtk struct */
40 	protected SoupCache* soupCache;
41 
42 	/** Get the main Gtk struct */
43 	public SoupCache* getCacheStruct(bool transferOwnership = false)
44 	{
45 		if (transferOwnership)
46 			ownedRef = false;
47 		return soupCache;
48 	}
49 
50 	/** the main Gtk struct as a void* */
51 	protected override void* getStruct()
52 	{
53 		return cast(void*)soupCache;
54 	}
55 
56 	/**
57 	 * Sets our main struct and passes it to the parent class.
58 	 */
59 	public this (SoupCache* soupCache, bool ownedRef = false)
60 	{
61 		this.soupCache = soupCache;
62 		super(cast(GObject*)soupCache, ownedRef);
63 	}
64 
65 	// add the SessionFeature capabilities
66 	mixin SessionFeatureT!(SoupCache);
67 
68 
69 	/** */
70 	public static GType getType()
71 	{
72 		return soup_cache_get_type();
73 	}
74 
75 	/**
76 	 * Creates a new #SoupCache.
77 	 *
78 	 * Params:
79 	 *     cacheDir = the directory to store the cached data, or %NULL
80 	 *         to use the default one. Note that since the cache isn't safe to access for
81 	 *         multiple processes at once, and the default directory isn't namespaced by
82 	 *         process, clients are strongly discouraged from passing %NULL.
83 	 *     cacheType = the #SoupCacheType of the cache
84 	 *
85 	 * Returns: a new #SoupCache
86 	 *
87 	 * Since: 2.34
88 	 *
89 	 * Throws: ConstructionException GTK+ fails to create the object.
90 	 */
91 	public this(string cacheDir, SoupCacheType cacheType)
92 	{
93 		auto __p = soup_cache_new(Str.toStringz(cacheDir), cacheType);
94 
95 		if(__p is null)
96 		{
97 			throw new ConstructionException("null returned by new");
98 		}
99 
100 		this(cast(SoupCache*) __p, true);
101 	}
102 
103 	/**
104 	 * Will remove all entries in the @cache plus all the cache files.
105 	 *
106 	 * Since: 2.34
107 	 */
108 	public void clear()
109 	{
110 		soup_cache_clear(soupCache);
111 	}
112 
113 	/**
114 	 * Synchronously writes the cache index out to disk. Contrast with
115 	 * soup_cache_flush(), which writes pending cache
116 	 * <emphasis>entries</emphasis> to disk.
117 	 *
118 	 * You must call this before exiting if you want your cache data to
119 	 * persist between sessions.
120 	 *
121 	 * Since: 2.34.
122 	 */
123 	public void dump()
124 	{
125 		soup_cache_dump(soupCache);
126 	}
127 
128 	/**
129 	 * This function will force all pending writes in the @cache to be
130 	 * committed to disk. For doing so it will iterate the #GMainContext
131 	 * associated with @cache's session as long as needed.
132 	 *
133 	 * Contrast with soup_cache_dump(), which writes out the cache index
134 	 * file.
135 	 *
136 	 * Since: 2.34
137 	 */
138 	public void flush()
139 	{
140 		soup_cache_flush(soupCache);
141 	}
142 
143 	/**
144 	 * Gets the maximum size of the cache.
145 	 *
146 	 * Returns: the maximum size of the cache, in bytes.
147 	 *
148 	 * Since: 2.34
149 	 */
150 	public uint getMaxSize()
151 	{
152 		return soup_cache_get_max_size(soupCache);
153 	}
154 
155 	/**
156 	 * Loads the contents of @cache's index into memory.
157 	 *
158 	 * Since: 2.34
159 	 */
160 	public void load()
161 	{
162 		soup_cache_load(soupCache);
163 	}
164 
165 	/**
166 	 * Sets the maximum size of the cache.
167 	 *
168 	 * Params:
169 	 *     maxSize = the maximum size of the cache, in bytes
170 	 *
171 	 * Since: 2.34
172 	 */
173 	public void setMaxSize(uint maxSize)
174 	{
175 		soup_cache_set_max_size(soupCache, maxSize);
176 	}
177 }